package com.xbongbong.paas.enums;

import com.xbongbong.paas.constant.EsAliasConstant;
import com.xbongbong.pro.config.ProBaseConfig;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 创建时间： 2018/10/15 14:43
 * 修改时间： 2018/10/15 14:43 梁鲁江
 *
 * @author 梁鲁江
 */
public enum IndexTypeEnum {
    /**
     * tb_paas_form_data对应的
     */
    IDX_FORM_DATA(1, EsAliasConstant.ALIAS + "idx_form_data", "form_data", "idx_form_data_v1"),
    /**
     * paas子表单
     */
    IDX_SUB_FORM_DATA(2, EsAliasConstant.ALIAS  + "idx_form_data", "sub_form_data", "idx_form_data_v1"),
    IDX_FORM_DATA_TEAM(XbbRefTypeEnum.PAAS_TEAM.getCode(), EsAliasConstant.ALIAS + "idx_form_data", "my_team", "idx_form_data_v1"),



    /**
     *  专门为统计3张图表设计
     */
    IDX_STATICS_MARKET_DATA(3, EsAliasConstant.ALIAS  + "idx_statics_market_data", "statics_date", "idx_statics_market_data"),

    IDX_SAAS_CUSTOMER(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), EsAliasConstant.ALIAS  + "idx_saas_customer_team", "saas_customer", "idx_saas_customer_team"),

    IDX_SAAS_CUSTOMER_TEAM(XbbRefTypeEnum.CUSTOMER_TEAM.getCode(), IDX_SAAS_CUSTOMER.index, "my_team",IDX_SAAS_CUSTOMER.realName),
    IDX_SAAS_CUSTOMER_SUB(XbbRefTypeEnum.CUSTOMER_SUBFORM.getCode(), IDX_SAAS_CUSTOMER.index, "sub_form_data",IDX_SAAS_CUSTOMER.realName),
//    IDX_SAAS_CUSTOMER(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(),"idx_saas_customer","saas_customer"),

    /**
     * 特殊客户索引，业务类型和普通客户业务类型一致，但是不能被白名单客户使用
     */
    IDX_SAAS_CUSTOMER_SPECIAL(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), EsAliasConstant.ALIAS  + "idx_saas_customer_team_special", "saas_customer", "idx_saas_customer_team_special"),
    IDX_SAAS_CUSTOMER_TEAM_SPECIAL(XbbRefTypeEnum.CUSTOMER_TEAM.getCode(), IDX_SAAS_CUSTOMER_SPECIAL.index, "my_team",IDX_SAAS_CUSTOMER_SPECIAL.realName),
    IDX_SAAS_CUSTOMER_SUB_SPECIAL(XbbRefTypeEnum.CUSTOMER_SUBFORM.getCode(), IDX_SAAS_CUSTOMER_SPECIAL.index, "sub_form_data",IDX_SAAS_CUSTOMER_SPECIAL.realName),

    IDX_SAAS_CONTRACT(XbbRefTypeEnum.CONTRACT.getCode(), EsAliasConstant.ALIAS + "idx_saas_contract", "saas_contract",  "idx_saas_contract"),
    IDX_SAAS_CONTRACT_PRODUCT(XbbRefTypeEnum.CONTRACT_PRODUCT.getCode(), IDX_SAAS_CONTRACT.index, "my_product",IDX_SAAS_CONTRACT.realName),
    IDX_SAAS_CONTRACT_TEAM(XbbRefTypeEnum.CONTRACT_TEAM.getCode(), IDX_SAAS_CONTRACT.index, "my_team",IDX_SAAS_CONTRACT.realName),
    IDX_SAAS_CONTRACT_PERFORMANCE(XbbRefTypeEnum.CONTRACT_PERFORMANCE.getCode(), IDX_SAAS_CONTRACT.index, "contract_performance",IDX_SAAS_CONTRACT.realName),
    IDX_SAAS_CONTRACT_SUB(XbbRefTypeEnum.CONTRACT_SUBFORM.getCode(), IDX_SAAS_CONTRACT.index, "sub_form_data",IDX_SAAS_CONTRACT.realName),

    IDX_SAAS_QUOTATION(XbbRefTypeEnum.QUOTATION.getCode(), EsAliasConstant.ALIAS + "idx_saas_quotation", "saas_quotation", "idx_saas_quotation"),
    IDX_SAAS_QUOTATION_TEAM(XbbRefTypeEnum.QUOTATION_TEAM.getCode(), IDX_SAAS_QUOTATION.index, "my_team",IDX_SAAS_QUOTATION.realName),
    IDX_SAAS_QUOTATION_SUB(XbbRefTypeEnum.QUOTATION_SUBFORM.getCode(), IDX_SAAS_QUOTATION.index, "sub_form_data",IDX_SAAS_QUOTATION.realName),


    IDX_SAAS_OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getCode(), EsAliasConstant.ALIAS + "idx_saas_outstock", "saas_outstock", "idx_saas_outstock"),
    IDX_SAAS_CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), IDX_SAAS_OUTSTOCK.index, "saas_outstock",IDX_SAAS_OUTSTOCK.realName),
    IDX_SAAS_RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), IDX_SAAS_OUTSTOCK.index, "saas_outstock",IDX_SAAS_OUTSTOCK.realName),
    IDX_SAAS_OTHER_OUTSTOCK(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), IDX_SAAS_OUTSTOCK.index, "saas_outstock",IDX_SAAS_OUTSTOCK.realName),
    IDX_SAAS_PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), IDX_SAAS_OUTSTOCK.index, "saas_outstock",IDX_SAAS_OUTSTOCK.realName),
    IDX_SAAS_WORK_ORDER_OUTSTOCK(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), IDX_SAAS_OUTSTOCK.index, "saas_outstock",IDX_SAAS_OUTSTOCK.realName),
    IDX_SAAS_OUTSTOCK_SUB(XbbRefTypeEnum.OUTSTOCK_SUBFORM.getCode(), IDX_SAAS_OUTSTOCK.index, "sub_form_data",IDX_SAAS_OUTSTOCK.realName),


    IDX_SAAS_CONTACT(XbbRefTypeEnum.CONTACT.getCode(), EsAliasConstant.ALIAS + "idx_saas_contact", "saas_contact", "idx_saas_contact"),
    IDX_SAAS_CONTACT_TEAM(XbbRefTypeEnum.CONTACT_TEAM.getCode(), IDX_SAAS_CONTACT.index, "my_team",IDX_SAAS_CONTACT.realName),
    IDX_SAAS_CONTACT_SUB(XbbRefTypeEnum.CONTACT_SUBFORM.getCode(), IDX_SAAS_CONTACT.index, "sub_form_data",IDX_SAAS_CONTACT.realName),


    IDX_SAAS_INVOICE(XbbRefTypeEnum.INVOICE.getCode(), EsAliasConstant.ALIAS  + "idx_saas_invoice", "saas_invoice", "idx_saas_invoice"),
    IDX_SAAS_INVOICE_EXPRESS(XbbRefTypeEnum.INVOICE_EXPRESS.getCode(), IDX_SAAS_INVOICE.index, "invoice_express", IDX_SAAS_INVOICE.realName),
    IDX_SAAS_INVOICE_SUB(XbbRefTypeEnum.INVOICE_SUBFORM.getCode(), IDX_SAAS_INVOICE.index, "sub_form_data",IDX_SAAS_INVOICE.realName),


    IDX_SAAS_PURCHASE_INVOICE(XbbRefTypeEnum.PURCHASE_INVOICE.getCode(), EsAliasConstant.ALIAS +"idx_saas_purchase_invoice","saas_purchase_invoice", "idx_saas_purchase_invoice"),
    IDX_SAAS_PURCHASE_INVOICE_EXPRESS(XbbRefTypeEnum.PURCHASE_INVOICE_EXPRESS.getCode(), IDX_SAAS_PURCHASE_INVOICE.index, "purchase_invoice_express", IDX_SAAS_PURCHASE_INVOICE.realName),
    IDX_SAAS_PURCHASE_INVOICE_SUB(XbbRefTypeEnum.PURCHASE_INVOICE_SUBFORM.getCode(),IDX_SAAS_PURCHASE_INVOICE.index,"sub_form_data",IDX_SAAS_PURCHASE_INVOICE.realName),


    IDX_SAAS_INSTOCK(XbbRefTypeEnum.INSTOCK.getCode(), EsAliasConstant.ALIAS + "idx_saas_instock", "saas_instock", "idx_saas_instock"),
    IDX_SAAS_PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), IDX_SAAS_INSTOCK.index, "saas_instock",IDX_SAAS_INSTOCK.realName),
    IDX_SAAS_REFUND_INSTOCK(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), IDX_SAAS_INSTOCK.index, "saas_instock",IDX_SAAS_INSTOCK.realName),
    IDX_SAAS_OTHER_INSTOCK(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), IDX_SAAS_INSTOCK.index, "saas_instock",IDX_SAAS_INSTOCK.realName),
    IDX_SAAS_PRODUCTION_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), IDX_SAAS_INSTOCK.index, "saas_instock",IDX_SAAS_INSTOCK.realName),
    IDX_SAAS_RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), IDX_SAAS_INSTOCK.index, "saas_instock",IDX_SAAS_INSTOCK.realName),
    IDX_SAAS_INSTOCK_SUB(XbbRefTypeEnum.INSTOCK_SUBFORM.getCode(), IDX_SAAS_INSTOCK.index, "sub_form_data",IDX_SAAS_INSTOCK.realName),


    IDX_SAAS_ASSEMBLE(XbbRefTypeEnum.ASSEMBLE.getCode(), EsAliasConstant.ALIAS + "idx_saas_assemble", "saas_assemble", "idx_saas_assemble"),
    IDX_SAAS_ASSEMBLE_SUB(XbbRefTypeEnum.ASSEMBLE_SUBFORM.getCode(), IDX_SAAS_ASSEMBLE.index, "sub_form_data",IDX_SAAS_ASSEMBLE.realName),

    IDX_SAAS_PAYMENT(XbbRefTypeEnum.PAYMENT.getCode(), EsAliasConstant.ALIAS + "idx_saas_payment", "saas_payment", "idx_saas_payment"),
    IDX_SAAS_PAYMENT_TEAM(XbbRefTypeEnum.PAYMENT_TEAM.getCode(), IDX_SAAS_PAYMENT.index, "my_team",IDX_SAAS_PAYMENT.realName),
    IDX_SAAS_PAYMENT_SUB(XbbRefTypeEnum.PAYMENT_SUBFORM.getCode(), IDX_SAAS_PAYMENT.index, "sub_form_data",IDX_SAAS_PAYMENT.realName),


    IDX_SAAS_PAYMENT_SHEET(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), EsAliasConstant.ALIAS + "idx_saas_payment_sheet", "saas_payment_sheet", "idx_saas_payment_sheet"),
    IDX_SAAS_PAYMENT_SHEET_TEAM(XbbRefTypeEnum.PAYMENT_SHEET_TEAM.getCode(), IDX_SAAS_PAYMENT_SHEET.index, "my_team",IDX_SAAS_PAYMENT_SHEET.realName),
    IDX_SAAS_PAYMENT_SHEET_SUB(XbbRefTypeEnum.PAYMENT_SHEET_SUBFORM.getCode(), IDX_SAAS_PAYMENT_SHEET.index, "sub_form_data",IDX_SAAS_PAYMENT_SHEET.realName),


    IDX_SAAS_PAYPLAN_SHEET(XbbRefTypeEnum.PAY_SHEET.getCode(), EsAliasConstant.ALIAS + "idx_saas_pay_sheet", "saas_pay_sheet", "idx_saas_pay_sheet"),
    IDX_SAAS_PAYPLAN_SHEET_TEAM(XbbRefTypeEnum.PAY_SHEET_TEAM.getCode(), IDX_SAAS_PAYPLAN_SHEET.index,"my_team",IDX_SAAS_PAYPLAN_SHEET.realName),
    IDX_SAAS_PAYPLAN_SHEET_SUB(XbbRefTypeEnum.PAY_SHEET_SUBFORM.getCode(), IDX_SAAS_PAYPLAN_SHEET.index, "sub_form_data",IDX_SAAS_PAYPLAN_SHEET.realName),


    IDX_SAAS_PRODUCTION_ORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), EsAliasConstant.ALIAS + "idx_saas_production_order", "saas_production_order", "idx_saas_production_order"),
    IDX_SAAS_PRODUCTION_ORDER_TEAM(XbbRefTypeEnum.PRODUCTION_ORDER_TEAM.getCode(), IDX_SAAS_PRODUCTION_ORDER.index, "my_team",IDX_SAAS_PRODUCTION_ORDER.realName),
    IDX_SAAS_PRODUCTION_ORDER_SUB(XbbRefTypeEnum.PRODUCTION_ORDER_SUBFORM.getCode(), IDX_SAAS_PRODUCTION_ORDER.index, "sub_form_data",IDX_SAAS_PRODUCTION_ORDER.realName),


    IDX_SAAS_PAY_PLAN(XbbRefTypeEnum.PAY_PLAN.getCode(), EsAliasConstant.ALIAS + "idx_saas_pay_plan", "saas_pay_plan", "idx_saas_pay_plan"),
    IDX_SAAS_PAY_PLAN_TEAM(XbbRefTypeEnum.PAY_PLAN_TEAM.getCode(), IDX_SAAS_PAY_PLAN.index, "my_team",IDX_SAAS_PAY_PLAN.realName),
    IDX_SAAS_PAY_PLAN_SUB(XbbRefTypeEnum.PAY_PLAN_SUBFORM.getCode(), IDX_SAAS_PAY_PLAN.index, "sub_form_data",IDX_SAAS_PAY_PLAN.realName),


    IDX_SAAS_COMMUNICATE_PLAN(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), EsAliasConstant.ALIAS + "idx_saas_communicate_plan", "saas_communicate_plan", "idx_saas_communicate_plan"),
    IDX_SAAS_COMMUNICATE_PLAN_TEAM(XbbRefTypeEnum.COMMUNICATE_PLAN_TEAM.getCode(), IDX_SAAS_COMMUNICATE_PLAN.index, "my_team",IDX_SAAS_COMMUNICATE_PLAN.realName),
    IDX_SAAS_COMMUNICATE_PLAN_SUB(XbbRefTypeEnum.COMMUNICATE_PLAN_SUBFORM.getCode(), IDX_SAAS_COMMUNICATE_PLAN.index, "sub_form_data",IDX_SAAS_COMMUNICATE_PLAN.realName),


    IDX_SAAS_OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), EsAliasConstant.ALIAS + "idx_saas_opportunity", "saas_opportunity", "idx_saas_opportunity"),
    IDX_SAAS_OPPORTUNITY_TEAM(XbbRefTypeEnum.SALES_OPPORTUNITY_TEAM.getCode(), IDX_SAAS_OPPORTUNITY.index, "my_team",IDX_SAAS_OPPORTUNITY.realName),
    IDX_SAAS_OPPORTUNITY_SUB(XbbRefTypeEnum.SALES_OPPORTUNITY_SUBFORM.getCode(), IDX_SAAS_OPPORTUNITY.index, "sub_form_data",IDX_SAAS_OPPORTUNITY.realName),


    IDX_SAAS_BOM(XbbRefTypeEnum.BOM_BILL.getCode(), EsAliasConstant.ALIAS + "idx_saas_bom", "saas_bom", "idx_saas_bom"),
    IDX_SAAS_BOM_TEAM(XbbRefTypeEnum.BOM_BILL_TEAM.getCode(), IDX_SAAS_BOM.index, "my_team",IDX_SAAS_BOM.realName),
    IDX_SAAS_BOM_SUB(XbbRefTypeEnum.BOM_BILL_SUBFORM.getCode(), IDX_SAAS_BOM.index, "sub_form_data",IDX_SAAS_BOM.realName),


    IDX_SAAS_CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), EsAliasConstant.ALIAS + "idx_saas_customer_communicate", "saas_customer_communicate", "idx_saas_customer_communicate"),
    IDX_SAAS_CUSTOMER_COMMUNICATE_SUB(XbbRefTypeEnum.CUSTOMER_COMMUNICATE_SUBFORM.getCode(), IDX_SAAS_CUSTOMER_COMMUNICATE.index, "sub_form_data",IDX_SAAS_CUSTOMER_COMMUNICATE.realName),

    IDX_SAAS_SUPPLIER_COMMUNICATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), EsAliasConstant.ALIAS + "idx_saas_supplier_communicate", "saas_supplier_communicate", "idx_saas_supplier_communicate"),
    IDX_SAAS_SUPPLIER_COMMUNICATE_SUB(XbbRefTypeEnum.SUPPLIER_COMMUNICATE_SUBFORM.getCode(), IDX_SAAS_SUPPLIER_COMMUNICATE.index, "sub_form_data",IDX_SAAS_SUPPLIER_COMMUNICATE.realName),

    IDX_SAAS_WORK_REPORT(XbbRefTypeEnum.WORK_REPORT.getCode(), EsAliasConstant.ALIAS +  "idx_saas_work_report", "saas_work_report", "idx_saas_work_report"),
    IDX_SAAS_WORK_REPORT_SUB(XbbRefTypeEnum.WORK_REPORT_SUBFORM.getCode(),IDX_SAAS_WORK_REPORT.index, "sub_form_data",IDX_SAAS_WORK_REPORT.realName),

    IDX_SAAS_PURCHASE(XbbRefTypeEnum.PURCHASE.getCode(), EsAliasConstant.ALIAS + "idx_saas_purchase", "saas_purchase", "idx_saas_purchase"),
    IDX_SAAS_PURCHASE_TEAM(XbbRefTypeEnum.PURCHASE_TEAM.getCode(), IDX_SAAS_PURCHASE.index, "my_team",IDX_SAAS_PURCHASE.realName),
    IDX_SAAS_PURCHASE_SUB(XbbRefTypeEnum.PURCHASE_SUBFORM.getCode(), IDX_SAAS_PURCHASE.index, "sub_form_data",IDX_SAAS_PURCHASE.realName),


    IDX_SAAS_RETURNED_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), EsAliasConstant.ALIAS + "idx_saas_returned_purchase", "saas_returned_purchase", "idx_saas_returned_purchase"),
    IDX_SAAS_RETURNED_PURCHASE_SUB(XbbRefTypeEnum.RETURNED_PURCHASE_SUBFORM.getCode(), IDX_SAAS_RETURNED_PURCHASE.index, "sub_form_data",IDX_SAAS_RETURNED_PURCHASE.realName),

    IDX_SAAS_SUPPLIER_CONTACT(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), EsAliasConstant.ALIAS +  "idx_saas_supplier_contact", "saas_supplier_contact", "idx_saas_supplier_contact"),
    IDX_SAAS_SUPPLIER_CONTACT_TEAM(XbbRefTypeEnum.SUPPLIER_CONTACT_TEAM.getCode(),IDX_SAAS_SUPPLIER_CONTACT.index, "my_team",IDX_SAAS_SUPPLIER_CONTACT.realName),
    IDX_SAAS_SUPPLIER_CONTACT_SUB(XbbRefTypeEnum.SUPPLIER_CONTACT_SUBFORM.getCode(),IDX_SAAS_SUPPLIER_CONTACT.index, "sub_form_data",IDX_SAAS_SUPPLIER_CONTACT.realName),


    IDX_SAAS_SUPPLIER(XbbRefTypeEnum.SUPPLIER.getCode(), EsAliasConstant.ALIAS + "idx_saas_supplier", "saas_supplier", "idx_saas_supplier"),
    IDX_SAAS_SUPPLIER_TEAM(XbbRefTypeEnum.SUPPLIER_TEAM.getCode(), IDX_SAAS_SUPPLIER.index, "my_team",IDX_SAAS_SUPPLIER.realName),
    IDX_SAAS_SUPPLIER_SUB(XbbRefTypeEnum.SUPPLIER_SUBFORM.getCode(), IDX_SAAS_SUPPLIER.index, "sub_form_data",IDX_SAAS_SUPPLIER.realName),


    IDX_SAAS_PRODUCT(XbbRefTypeEnum.PRODUCT.getCode(), EsAliasConstant.ALIAS + "idx_saas_product", "saas_product", "idx_saas_product"),
    IDX_SAAS_PRODUCT_TEAM(XbbRefTypeEnum.PRODUCT_TEAM.getCode(), IDX_SAAS_PRODUCT.index, "my_team",IDX_SAAS_PRODUCT.realName),
    IDX_SAAS_PRODUCT_WAREHOUSE(XbbRefTypeEnum.PRODUCT_WAREHOUSE.getCode(), IDX_SAAS_PRODUCT.index, "product_warehouse",IDX_SAAS_PRODUCT.realName),
    IDX_SAAS_PRODUCT_STOCK_INFO(XbbRefTypeEnum.PRODUCT_STOCK_INFO.getCode(), IDX_SAAS_PRODUCT.index, "product_stock_info",IDX_SAAS_PRODUCT.realName),
    IDX_SAAS_PRODUCT_SUB(XbbRefTypeEnum.PRODUCT_SUBFORM.getCode(), IDX_SAAS_PRODUCT.index, "sub_form_data",IDX_SAAS_PRODUCT.realName),

    IDX_SAAS_INVENTORY(XbbRefTypeEnum.INVENTORY.getCode(), EsAliasConstant.ALIAS +  "idx_saas_inventory", "saas_inventory", "idx_saas_inventory"),
    IDX_SAAS_INVENTORY_SUB(XbbRefTypeEnum.INVENTORY_SUBFORM.getCode(),IDX_SAAS_INVENTORY.index, "sub_form_data",IDX_SAAS_INVENTORY.realName),

    IDX_SAAS_TRANSFER(XbbRefTypeEnum.TRANSFER.getCode(), EsAliasConstant.ALIAS +  "idx_saas_transfer", "saas_transfer", "idx_saas_transfer"),
    IDX_SAAS_TRANSFER_SUB(XbbRefTypeEnum.TRANSFER_SUBFORM.getCode(),IDX_SAAS_TRANSFER.index, "sub_form_data",IDX_SAAS_TRANSFER.realName),

    IDX_SAAS_WAREHOUSE(XbbRefTypeEnum.WAREHOUSE.getCode(), EsAliasConstant.ALIAS + "idx_saas_warehouse", "saas_warehouse", "idx_saas_warehouse"),
    IDX_SAAS_WAREHOUSE_SUB(XbbRefTypeEnum.WAREHOUSE_SUBFORM.getCode(), IDX_SAAS_WAREHOUSE.index, "sub_form_data",IDX_SAAS_WAREHOUSE.realName),

    IDX_SAAS_REFUND(XbbRefTypeEnum.REFUND.getCode(), EsAliasConstant.ALIAS  + "idx_saas_refund", "saas_refund", "idx_saas_refund"),
    IDX_SAAS_REFUND_TEAM(XbbRefTypeEnum.REFUND_TEAM.getCode(), IDX_SAAS_REFUND.index, "my_team",IDX_SAAS_REFUND.realName),
    IDX_SAAS_REFUND_SUB(XbbRefTypeEnum.REFUND_SUBFORM.getCode(), IDX_SAAS_REFUND.index, "sub_form_data",IDX_SAAS_REFUND.realName),

    IDX_SAAS_WORK_ORDER(XbbRefTypeEnum.WORK_ORDER.getCode(), EsAliasConstant.ALIAS + "idx_saas_work_order", "saas_work_order", "idx_saas_work_order"),
    IDX_SAAS_WORK_ORDER_TEAM(XbbRefTypeEnum.WORK_ORDER_TEAM.getCode(), IDX_SAAS_WORK_ORDER.index, "my_team",IDX_SAAS_WORK_ORDER.realName),
    IDX_SAAS_WORK_ORDER_CC(XbbRefTypeEnum.WORK_ORDER_CC.getCode(), IDX_SAAS_WORK_ORDER.index, "my_cc",IDX_SAAS_WORK_ORDER.realName),
    IDX_SAAS_WORK_ORDER_SUB(XbbRefTypeEnum.WORK_ORDER_SUBFORM.getCode(), IDX_SAAS_WORK_ORDER.index, "sub_form_data",IDX_SAAS_WORK_ORDER.realName),

    IDX_SAAS_ORISTOCK(XbbRefTypeEnum.ORI_STOCK.getCode(), EsAliasConstant.ALIAS + "idx_saas_ori_stock", "saas_ori_stock", "idx_saas_ori_stock"),

    /**
     * 信用额度、固定额度、临时额度
     */
    IDX_SAAS_CREDIT_LIMIT(XbbRefTypeEnum.CREDIT_LIMIT.getCode(), EsAliasConstant.ALIAS + "idx_saas_credit_limit", "saas_credit_limit", "idx_saas_credit_limit"),
    IDX_SAAS_CREDIT_FIXED_LIMIT(XbbRefTypeEnum.CREDIT_FIXED_LIMIT.getCode(), EsAliasConstant.ALIAS + "idx_saas_credit_fixed_limit", "saas_credit_fixed_limit", "idx_saas_credit_fixed_limit"),
    IDX_SAAS_CREDIT_FIXED_LIMIT_SUB(XbbRefTypeEnum.CREDIT_FIXED_LIMIT_SUBFORM.getCode(), IDX_SAAS_CREDIT_FIXED_LIMIT.index, "sub_form_data", IDX_SAAS_CREDIT_FIXED_LIMIT.realName),
    IDX_SAAS_CREDIT_TEMPORARY_LIMIT(XbbRefTypeEnum.CREDIT_TEMPORARY_LIMIT.getCode(), EsAliasConstant.ALIAS + "idx_saas_credit_temporary_limit", "saas_credit_temporary_limit", "idx_saas_credit_temporary_limit"),
    IDX_SAAS_CREDIT_TEMPORARY_LIMIT_SUB(XbbRefTypeEnum.CREDIT_TEMPORARY_LIMIT_SUBFORM.getCode(), IDX_SAAS_CREDIT_TEMPORARY_LIMIT.index, "sub_form_data", IDX_SAAS_CREDIT_TEMPORARY_LIMIT.realName),
    IDX_SAAS_CREDIT_CARD_BILL(XbbRefTypeEnum.CREDIT_CARD_BILL.getCode(), EsAliasConstant.ALIAS + "idx_saas_credit_card_bill", "saas_credit_card_bill", "idx_saas_credit_card_bill"),

    /**
     * 通话记录索引
     */
    IDX_CALL_CENTER_CALL_LOG(XbbRefTypeEnum.CALL_CENTER_CALL_LOG.getCode(), EsAliasConstant.ALIAS + "idx_call_center_call_log", "call_center_call_log", "idx_call_center_call_log_add_aliyun"),
    /**
     * 预收款余额
     */
    IDX_PAYMENT_BALANCE (XbbRefTypeEnum.PREPAYMENT_BALANCE.getCode(), EsAliasConstant.ALIAS + "idx_payment_balance", "payment_balance", "idx_payment_balance"),
    IDX_PAYMENT_BALANCE_TEAM (XbbRefTypeEnum.PREPAYMENT_BALANCE_TEAM.getCode(), IDX_PAYMENT_BALANCE.index, "my_team",IDX_PAYMENT_BALANCE.realName),
    /**
     * 预付款余额
     */
    IDX_PAY_BALANCE (XbbRefTypeEnum.PREPAY_BALANCE.getCode(), EsAliasConstant.ALIAS + "idx_pay_balance", "pay_balance", "idx_pay_balance"),
    IDX_PAY_BALANCE_TEAM (XbbRefTypeEnum.PREPAY_BALANCE_TEAM.getCode(), IDX_PAY_BALANCE.index, "my_team",IDX_PAY_BALANCE.realName),

    /**
     * 资金账户流水
     */
    IDX_FUND_ACCOUNT_FLOW (XbbRefTypeEnum.FUND_ACCOUNT_FLOW.getCode(), EsAliasConstant.ALIAS + "idx_fund_account_flow", "fund_account_flow", "idx_fund_account_flow"),

    /**
     * 其他收入单
     */
    IDX_SAAS_OTHER_INCOME (XbbRefTypeEnum.OTHER_INCOME.getCode(), EsAliasConstant.ALIAS + "idx_saas_other_income", "saas_other_income", "idx_saas_other_income"),
    IDX_SAAS_OTHER_INCOME_SUB(XbbRefTypeEnum.OTHER_INCOME_SUBFORM.getCode(), IDX_SAAS_OTHER_INCOME.index, "sub_form_data",IDX_SAAS_OTHER_INCOME.realName),
    /**
     * 其他支出单
     */
    IDX_SAAS_OTHER_EXPENSE (XbbRefTypeEnum.OTHER_EXPENSE.getCode(), EsAliasConstant.ALIAS + "idx_saas_other_expense", "saas_other_expense", "idx_saas_other_expense"),
    IDX_SAAS_OTHER_EXPENSE_SUB(XbbRefTypeEnum.OTHER_EXPENSE_SUBFORM.getCode(), IDX_SAAS_OTHER_EXPENSE.index, "sub_form_data",IDX_SAAS_OTHER_EXPENSE.realName),
    /**
     * 资金调拨单
     */
    IDX_SAAS_FUND_TRANSFER (XbbRefTypeEnum.FUND_TRANSFER.getCode(), EsAliasConstant.ALIAS + "idx_saas_fund_transfer", "saas_fund_transfer", "idx_saas_fund_transfer"),
    IDX_SAAS_FUND_TRANSFER_SUB(XbbRefTypeEnum.FUND_TRANSFER_SUBFORM.getCode(), IDX_SAAS_FUND_TRANSFER.index, "sub_form_data",IDX_SAAS_FUND_TRANSFER.realName),

    IDX_SAAS_REIMBURSEMENT_FORM(XbbRefTypeEnum.REIMBURSEMENT_FORM.getCode(), EsAliasConstant.ALIAS + "idx_saas_reimbursement_form", "saas_reimbursement_form", "idx_saas_reimbursement_form"),

    IDX_SAAS_EXPENSE(XbbRefTypeEnum.EXPENSE.getCode(), EsAliasConstant.ALIAS + "idx_saas_expense", "saas_expense", "idx_saas_expense"),
    /**
     * 销售线索
     */
    IDX_SAAS_CLUE(XbbRefTypeEnum.CLUE.getCode(), EsAliasConstant.ALIAS + "idx_saas_clue", "saas_clue","idx_saas_clue"),
    IDX_SAAS_CLUE_TEAM (XbbRefTypeEnum.CLUE_TEAM.getCode(), IDX_SAAS_CLUE.index, "my_team",IDX_SAAS_CLUE.realName),
    IDX_SAAS_CLUE_SUB(XbbRefTypeEnum.CLUE_SUBFORM.getCode(), IDX_SAAS_CLUE.index, "sub_form_data",IDX_SAAS_CLUE.realName),

    /**
     * 市场活动
     */
    IDX_SAAS_MARKET_ACTIVITY (XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), EsAliasConstant.ALIAS + "idx_saas_market_activity", "saas_market_activity","idx_saas_market_activity"),
    IDX_SAAS_MARKET_ACTIVITY_TEAM (XbbRefTypeEnum.MARKET_ACTIVITY_TEAM.getCode(), IDX_SAAS_MARKET_ACTIVITY.index, "my_team",IDX_SAAS_MARKET_ACTIVITY.realName),
    IDX_SAAS_MARKET_ACTIVITY_SUB(XbbRefTypeEnum.MARKET_ACTIVITY_SUBFORM.getCode(), IDX_SAAS_MARKET_ACTIVITY.index, "sub_form_data",IDX_SAAS_MARKET_ACTIVITY.realName),

    /**
     * 新回款计划
     */
    IDX_SAAS_PAYMENT_TASK(XbbRefTypeEnum.PAYMENT_TASK.getCode(), EsAliasConstant.ALIAS + "idx_saas_payment_task", "saas_payment_task", "idx_saas_payment_task"),
    IDX_SAAS_PAYMENT_TASK_TEAM(XbbRefTypeEnum.PAYMENT_TASK_TEAM.getCode(), IDX_SAAS_PAYMENT_TASK.index, "my_team", IDX_SAAS_PAYMENT_TASK.realName),
    IDX_SAAS_PAYMENT_TASK_SUB(XbbRefTypeEnum.PAYMENT_TASK_SUBFORM.getCode(), IDX_SAAS_PAYMENT_TASK.index, "sub_form_data", IDX_SAAS_PAYMENT_TASK.realName),

    IDX_SAAS_CUSTOMER_STATEMENT(XbbRefTypeEnum.CUSTOMER_STATEMENT.getCode(), EsAliasConstant.ALIAS + "idx_saas_customer_statement", "saas_customer_statement", "idx_saas_customer_statement"),

    IDX_SAAS_STATEMENT(XbbRefTypeEnum.CUSTOMER_STATEMENT_STATISTIC.getCode(),  EsAliasConstant.ALIAS + "idx_saas_statement", "saas_statement", "idx_saas_statement"),
    IDX_SAAS_CUSTOMER_STATEMENT_SNAPSHOT(XbbRefTypeEnum.CUSTOMER_STATEMENT_SNAPSHOT.getCode(), IDX_SAAS_STATEMENT.index, "statement_snapshot", IDX_SAAS_STATEMENT.realName),

    /**
     * 在线支付流水
     */
    IDX_ONLINE_PAYMENT_FLOW (XbbRefTypeEnum.ONLINE_PAYMENT_FLOW.getCode(), EsAliasConstant.ALIAS + "idx_online_payment_flow", "online_payment_flow", "idx_online_payment_flow"),

    /**
     * 营销活动
     */
    IDX_SAAS_MARKETING_ACTIVITY_MANAGEMENT(XbbRefTypeEnum.MARKETING_ACTIVITY_MANAGEMENT.getCode(), EsAliasConstant.ALIAS + "idx_saas_marketing_activity_management", "saas_marketing_activity_management", "idx_saas_marketing_activity_management"),

    /**
     * 促销活动
     */
    IDX_SAAS_PROMOTION_ACTIVITY_MANAGEMENT(XbbRefTypeEnum.PROMOTION_ACTIVITY_MANAGEMENT.getCode(), EsAliasConstant.ALIAS + "idx_saas_promotion_activity_management", "saas_promotion_activity_management", "idx_saas_promotion_activity_management"),

    IDX_SAAS_DISTRIBUTOR_ACCOUNT(XbbRefTypeEnum.DISTRIBUTOR_ACCOUNT.getCode(), EsAliasConstant.ALIAS + "idx_saas_distributor_account", "distributor_account", "idx_saas_distributor_account"),

    /**
     * 成本调整单
     */
    IDX_SAAS_COST_ADJUST(XbbRefTypeEnum.COST_ADJUST.getCode(), EsAliasConstant.ALIAS +  "idx_saas_cost_adjust", "saas_cost_adjust", "idx_saas_cost_adjust"),
    IDX_SAAS_COST_ADJUST_SUB(XbbRefTypeEnum.COST_ADJUST_SUBFORM.getCode(), IDX_SAAS_COST_ADJUST.index, "sub_form_data",IDX_SAAS_COST_ADJUST.realName),

    /**
     * 知识库
     */
    IDX_SAAS_KNOWLEDGE_DATA(XbbRefTypeEnum.KNOWLEDGE_BASE.getCode(), EsAliasConstant.ALIAS + "idx_saas_knowledge_data", "saas_knowledge_data", "idx_saas_knowledge_data"),

    /**
     * 新工单
     */
    IDX_WORK_ORDER_V2 (XbbRefTypeEnum.WORK_ORDER_V2.getCode(), EsAliasConstant.ALIAS + "idx_work_order_v2", "work_order_v2","idx_work_order_v2"),
    IDX_WORK_ORDER_V2_TEAM (XbbRefTypeEnum.WORK_ORDER_V2_TEAM.getCode(), IDX_WORK_ORDER_V2.index, "my_team",IDX_WORK_ORDER_V2.realName),
    IDX_WORK_ORDER_V2_PRODUCT(XbbRefTypeEnum.WORK_ORDER_V2_PRODUCT.getCode(), IDX_WORK_ORDER_V2.index, "my_product",IDX_WORK_ORDER_V2.realName),
    IDX_WORK_ORDER_V2_SUB(XbbRefTypeEnum.WORK_ORDER_V2_SUBFORM.getCode(), IDX_WORK_ORDER_V2.index, "sub_form_data",IDX_WORK_ORDER_V2.realName),
    IDX_WORK_ORDER_V2_NODE_INFO(XbbRefTypeEnum.WORK_ORDER_V2_NODE_INFO.getCode(), EsAliasConstant.ALIAS  + "idx_work_order_v2_node_info", "statics_date", "idx_work_order_v2_node_info"),
    /**
     * sla 日志
     */
    IDX_SLA_LOG_DATA(XbbRefTypeEnum.SLA_LOG.getCode(),EsAliasConstant.ALIAS + "idx_sla_log_data","sla_log","idx_sla_log_data"),
    IDX_SLA_LOG_DATA_TEAM(XbbRefTypeEnum.SLA_LOG_TEAM.getCode(),IDX_SLA_LOG_DATA.index,"my_team",IDX_SLA_LOG_DATA.realName),
    /**
     * 回执单
     */
    IDX_RECEIPT_ORDER(XbbRefTypeEnum.RECEIPT_ORDER.getCode(), EsAliasConstant.ALIAS +  "idx_receipt_order", "receipt_order", "idx_receipt_order"),
    IDX_RECEIPT_ORDER_PRODUCT(XbbRefTypeEnum.RECEIPT_ORDER_PRODUCT.getCode(), IDX_RECEIPT_ORDER.index, "my_product",IDX_RECEIPT_ORDER.realName),
    IDX_RECEIPT_ORDER_TEAM(XbbRefTypeEnum.RECEIPT_ORDER_TEAM.getCode(), IDX_RECEIPT_ORDER.index, "my_team",IDX_RECEIPT_ORDER.realName),
    IDX_RECEIPT_ORDER_SUB(XbbRefTypeEnum.RECEIPT_ORDER_SUBFORM.getCode(), IDX_RECEIPT_ORDER.index, "sub_form_data",IDX_RECEIPT_ORDER.realName),
    /**
     * 服务项目
     */
    IDX_SERVICE_PROJECT (XbbRefTypeEnum.SERVICE_PROJECT.getCode(), EsAliasConstant.ALIAS + "idx_service_project", "service_project","idx_service_project"),
    IDX_SERVICE_PROJECT_TEAM (XbbRefTypeEnum.SERVICE_PROJECT_TEAM.getCode(), IDX_SERVICE_PROJECT.index, "my_team",IDX_SERVICE_PROJECT.realName),
    IDX_SERVICE_PROJECT_SUB(XbbRefTypeEnum.SERVICE_PROJECT_SUBFORM.getCode(), IDX_SERVICE_PROJECT.index, "sub_form_data",IDX_SERVICE_PROJECT.realName),

    /**
     * 竞争对手
     */
    IDX_SAAS_COMPETITOR(XbbRefTypeEnum.COMPETITOR.getCode(), EsAliasConstant.ALIAS + "idx_saas_competitor", "saas_competitor", "idx_saas_competitor"),
    IDX_SAAS_COMPETITOR_TEAM(XbbRefTypeEnum.COMPETITOR_TEAM.getCode(), IDX_SAAS_COMPETITOR.index, "my_team",IDX_SAAS_COMPETITOR.realName),
    IDX_SAAS_COMPETITOR_SUB(XbbRefTypeEnum.COMPETITOR_SUBFORM.getCode(), IDX_SAAS_COMPETITOR.index, "sub_form_data",IDX_SAAS_COMPETITOR.realName),

    /**
     * 合同比对
     */
    IDX_CONTRACT_COMPARE(XbbRefTypeEnum.CONTRACT_COMPARE_RESULT.getCode(), EsAliasConstant.ALIAS + "idx_contract_compare", "contract_compare", "idx_contract_compare"),

    UNKNOWN(404, "404", "404",""),;
    /**
     * 编号标示
     */
    private Integer code;
    /**
     * index
     */
    private String index;
    /**
     * type
     */
    private String type;
    /**
     *
     */
    private String realName;

    public Integer getCode() {
        return code;
    }

    public String getIndex() {
        return ProBaseConfig.getEsName() + index;
    }

    public String getType() {
        return type;
    }

    public String getRealName(){
        return ProBaseConfig.getEsName() + realName;
    }
    IndexTypeEnum(Integer code, String index, String type,String realName) {
        this.code = code;
        this.index = index;
        this.type = type;
        this.realName = realName;
    }


    /**
     * 通过枚举<code>alias</code>获得枚举
     *
     * @param alias
     * @return IndexTypeEnum
     */
    public static IndexTypeEnum getIndex(String alias) {
        for (IndexTypeEnum cacheCode : values()) {
            if (cacheCode.getIndex().equals(alias)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    /**
     * 通过枚举<code>code</code>获得枚举
     *
     * @param code
     * @return IndexTypeEnum
     */
    public static IndexTypeEnum getByCode(Integer code) {
        code = XbbRefTypeEnum.transferBusinessType2Index(code);
        List<IndexTypeEnum> list = Arrays.asList(IndexTypeEnum.IDX_SAAS_CUSTOMER_SPECIAL, IndexTypeEnum.IDX_SAAS_CUSTOMER_TEAM_SPECIAL, IndexTypeEnum.IDX_SAAS_CUSTOMER_SUB_SPECIAL);
        for (IndexTypeEnum cacheCode : values()) {
            if (Objects.equals(XbbRefTypeEnum.WORKREPORT_DAILY.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.WORKREPORT_WEEKLY.getCode(), code)
                    ||Objects.equals(XbbRefTypeEnum.WORKREPORT_MONTHLY.getCode(), code) ) {
                return IndexTypeEnum.IDX_SAAS_WORK_REPORT;
            } else if(Objects.equals(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.BAD_DEBT.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_PAYMENT_SHEET.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_WRITE_OFF_PREPAYMENT.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_WRITE_OFF_BALANCE.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_PREPAYMENT.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.PREPAYMENT.getCode(), code)
                    ||Objects.equals(XbbRefTypeEnum.WRITE_OFF_PREPAYMENT.getCode(), code)){
                return IndexTypeEnum.IDX_SAAS_PAYMENT_SHEET;
            } else if (Objects.equals(XbbRefTypeEnum.PAY_SHEET.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.BAD_PAY.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_WRITE_OFF_PAY.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_WRITE_OFF_PREPAY.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_PREPAY.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.PREPAY.getCode(), code)
                    ||Objects.equals(XbbRefTypeEnum.WRITE_OFF_PREPAY.getCode(), code)) {
                return IndexTypeEnum.IDX_SAAS_PAYPLAN_SHEET;
            }else if (Objects.equals(XbbRefTypeEnum.PAYMENT.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_RECEIVABLES.getCode(), code)){
                return IndexTypeEnum.IDX_SAAS_PAYMENT;
            }else if (Objects.equals(XbbRefTypeEnum.OTHER_INCOME.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_OTHER_INCOME.getCode(), code)) {
                return IndexTypeEnum.IDX_SAAS_OTHER_INCOME;
            } else if (Objects.equals(XbbRefTypeEnum.OTHER_EXPENSE.getCode(), code)
                    || Objects.equals(XbbRefTypeEnum.RED_OTHER_EXPENSE.getCode(), code)) {
                return IndexTypeEnum.IDX_SAAS_OTHER_EXPENSE;
            }else if (Objects.equals(XbbRefTypeEnum.PAAS.getCode(), code)) {
                return IndexTypeEnum.IDX_FORM_DATA;
            }else if (Objects.equals(XbbRefTypeEnum.WAIT_PURCHASE.getCode(), code)){
                return IndexTypeEnum.IDX_SAAS_CONTRACT;
            }else if (cacheCode.getCode().equals(code) && !list.contains(cacheCode)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    /**
     * 获取全部枚举
     *
     * @return List<IndexTypeEnum>
     */
    public static List<IndexTypeEnum> getAllEnum() {
        List<IndexTypeEnum> list = new ArrayList<>();
        for (IndexTypeEnum cache : values()) {
            if (filterInvalid(cache)) {
                continue;
            }
            list.add(cache);
        }
        return list;
    }

    /**
     * 获取全部枚举值
     *
     * @return List<String>
     */
    public  static List<String> getAllEnumAlis() {
        List<String> list = new ArrayList<>();
        for (IndexTypeEnum cache : values()) {
            if (filterInvalid(cache)) {
                continue;
            }
            list.add(cache.index);
        }
        return list;
    }

    /**
     * 过滤不存在的索引
     * @param cache
     * @return boolean
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    private static boolean filterInvalid(IndexTypeEnum cache) {
        Integer code = cache.getCode();
        return Objects.isNull(cache) || Objects.equals(code, UNKNOWN.getCode()) || Objects.equals(code, IDX_SAAS_PAYMENT_TASK.getCode()) || Objects.equals(code, IDX_SAAS_PAYMENT_TASK_TEAM.getCode()) || Objects.equals(code, IDX_SAAS_PAYMENT_TASK_SUB.getCode());
    }

    /**
     * 已核对完，只是获取index中的type @date 2022/4/29 14:32
     * @param businessType
     * @return
     */
    public static IndexTypeEnum getChildByParent(Integer businessType) {
        if (Objects.isNull(businessType)){
            return UNKNOWN;
        }
        businessType = XbbRefTypeEnum.transferBusinessType2Index(businessType);
        IndexTypeEnum indexTypeEnum = IndexTypeEnum.getByCode(businessType);
        switch (indexTypeEnum){
            case IDX_SAAS_CUSTOMER:
                return IDX_SAAS_CUSTOMER_TEAM;
            case IDX_SAAS_CUSTOMER_SPECIAL:
                return IDX_SAAS_CUSTOMER_TEAM_SPECIAL;
            case IDX_SAAS_CONTRACT:
                return IDX_SAAS_CONTRACT_TEAM;
            case IDX_SAAS_OPPORTUNITY:
                return IDX_SAAS_OPPORTUNITY_TEAM;
            case IDX_SAAS_CONTACT:
                return IDX_SAAS_CONTACT_TEAM;
            case IDX_SAAS_REFUND:
                return IDX_SAAS_REFUND_TEAM;
            case IDX_SAAS_PAYMENT:
                return IDX_SAAS_PAYMENT_TEAM;
            case IDX_SAAS_PAY_PLAN:
                return IDX_SAAS_PAY_PLAN_TEAM;
            case IDX_SAAS_SUPPLIER:
                return IDX_SAAS_SUPPLIER_TEAM;
            case IDX_SAAS_SUPPLIER_CONTACT:
                return IDX_SAAS_SUPPLIER_CONTACT_TEAM;
            case IDX_SAAS_PURCHASE:
                return IDX_SAAS_PURCHASE_TEAM;
            case IDX_SAAS_BOM:
                return IDX_SAAS_BOM_TEAM;
            case IDX_SAAS_PRODUCTION_ORDER:
                return IDX_SAAS_PRODUCTION_ORDER_TEAM;
            case IDX_SAAS_PRODUCT:
                return IDX_SAAS_PRODUCT_TEAM;
            case IDX_SAAS_WORK_ORDER:
                return IDX_SAAS_WORK_ORDER_TEAM;
            case IDX_SAAS_COMMUNICATE_PLAN:
                return IDX_SAAS_COMMUNICATE_PLAN_TEAM;
            case IDX_SAAS_QUOTATION:
                return IDX_SAAS_QUOTATION_TEAM;
            case IDX_PAYMENT_BALANCE:
                return IDX_PAYMENT_BALANCE_TEAM;
            case IDX_PAY_BALANCE:
                return IDX_PAY_BALANCE_TEAM;
            case IDX_SAAS_PAYMENT_SHEET:
                return IDX_SAAS_PAYMENT_SHEET_TEAM;
            case IDX_SAAS_PAYPLAN_SHEET:
                return IDX_SAAS_PAYPLAN_SHEET_TEAM;
            case IDX_SAAS_PAYMENT_TASK:
                return IDX_SAAS_PAYMENT_TASK_TEAM;
            case IDX_SAAS_MARKET_ACTIVITY:
                return IDX_SAAS_MARKET_ACTIVITY_TEAM;
            case IDX_SAAS_CLUE:
                return IDX_SAAS_CLUE_TEAM;
            case IDX_FORM_DATA:
                return IDX_FORM_DATA_TEAM;
            case IDX_SAAS_COMPETITOR:
                return IDX_SAAS_COMPETITOR_TEAM;
            case IDX_SERVICE_PROJECT:
                return IDX_SERVICE_PROJECT_TEAM;
            case IDX_RECEIPT_ORDER:
                return IDX_RECEIPT_ORDER_TEAM;
            case IDX_WORK_ORDER_V2:
                return IDX_WORK_ORDER_V2_TEAM;
            case IDX_SLA_LOG_DATA:
                return IDX_SLA_LOG_DATA_TEAM;
            default:
                    break;
        }
        return UNKNOWN;
    }

    /**
     * 通过父indexTypeEnum获取对应的子表单
     * @param indexTypeEnum
     * @return
     */
    public static IndexTypeEnum getSubFormByParent(IndexTypeEnum indexTypeEnum) {
        if (Objects.isNull(indexTypeEnum) || Objects.equals(indexTypeEnum, UNKNOWN)) {
            return UNKNOWN;
        }
        String index = indexTypeEnum.getIndex();
        for (IndexTypeEnum cache : values()) {
            if (Objects.equals(index, cache.getIndex()) && Objects.equals("sub_form_data", cache.getType())) {
                return cache;
            }
        }
        return UNKNOWN;
    }

    public static IndexTypeEnum getCopyChildByParent(Integer businessType) {
        if (Objects.isNull(businessType)){
            return UNKNOWN;
        }
        IndexTypeEnum indexTypeEnum = IndexTypeEnum.getByCode(businessType);
        switch (indexTypeEnum) {
            case IDX_SAAS_WORK_ORDER:
                return IDX_SAAS_WORK_ORDER_CC;
            default:
                break;
        }
        return UNKNOWN;
    }
    /**
     * 获取全部code
     *
     * @return List<String>
     */
    public static List<Integer> getAllEnumCode() {
        List<Integer> list = new ArrayList<>();
        for (IndexTypeEnum cache : values()) {
            if (filterInvalid(cache)) {
                continue;
            }
            list.add(cache.getCode());
        }
        return list;
    }

    public static IndexTypeEnum getSubEnum(IndexTypeEnum indexTypeEnum){
        return getSubByIndexEnum(indexTypeEnum);
    }


    public static IndexTypeEnum getSubIndexByCode(Integer businessType){
        IndexTypeEnum byCode = getByCode(businessType);
        return getSubByIndexEnum(byCode);
    }

    public static IndexTypeEnum getSubByIndexEnum(IndexTypeEnum indexTypeEnum) {
        if (Objects.isNull(indexTypeEnum)){
            return UNKNOWN;
        }
        switch (indexTypeEnum){
            case IDX_FORM_DATA:
                return IDX_SUB_FORM_DATA;
            case IDX_SAAS_CUSTOMER:
                return IDX_SAAS_CUSTOMER_SUB;
            case IDX_SAAS_CUSTOMER_SPECIAL:
                // 客户特殊的索引
                return IDX_SAAS_CUSTOMER_SUB_SPECIAL;
            case IDX_SAAS_CONTRACT:
                return IDX_SAAS_CONTRACT_SUB;
            case IDX_SAAS_QUOTATION:
                return IDX_SAAS_QUOTATION_SUB;
            case IDX_SAAS_OUTSTOCK:
            case IDX_SAAS_OTHER_OUTSTOCK:
            case IDX_SAAS_CONTRACT_OUTSTOCK:
            case IDX_SAAS_WORK_ORDER_OUTSTOCK:
            case IDX_SAAS_RETURNED_PURCHASE_OUTSTOCK:
            case IDX_SAAS_PRODUCTION_MATERIEL_OUTSTOCK:
                return IDX_SAAS_OUTSTOCK_SUB;
            case IDX_SAAS_CONTACT:
                return IDX_SAAS_CONTACT_SUB;
            case IDX_SAAS_INVOICE:
                return IDX_SAAS_INVOICE_SUB;
            case IDX_SAAS_PURCHASE_INVOICE:
                return IDX_SAAS_PURCHASE_INVOICE_SUB;
            case IDX_SAAS_INSTOCK:
            case IDX_SAAS_REFUND_INSTOCK:
            case IDX_SAAS_PURCHASE_INSTOCK:
            case IDX_SAAS_PRODUCTION_INSTOCK:
            case IDX_SAAS_RETURNED_MATERIEL_INSTOCK:
            case IDX_SAAS_OTHER_INSTOCK:
                return IDX_SAAS_INSTOCK_SUB;
            case IDX_SAAS_ASSEMBLE:
                return IDX_SAAS_ASSEMBLE_SUB;
            case IDX_SAAS_PAYMENT:
                return IDX_SAAS_PAYMENT_SUB;
            case IDX_SAAS_PAYMENT_SHEET:
                return IDX_SAAS_PAYMENT_SHEET_SUB;
            case IDX_SAAS_PAYPLAN_SHEET:
                return IDX_SAAS_PAYPLAN_SHEET_SUB;
            case IDX_SAAS_PRODUCTION_ORDER:
                return IDX_SAAS_PRODUCTION_ORDER_SUB;
            case IDX_SAAS_PAY_PLAN:
                return IDX_SAAS_PAY_PLAN_SUB;
            case IDX_SAAS_COMMUNICATE_PLAN:
                return IDX_SAAS_COMMUNICATE_PLAN_SUB;
            case IDX_SAAS_OPPORTUNITY:
                return IDX_SAAS_OPPORTUNITY_SUB;
            case IDX_SAAS_BOM:
                return IDX_SAAS_BOM_SUB;
            case IDX_SAAS_CUSTOMER_COMMUNICATE:
                return IDX_SAAS_CUSTOMER_COMMUNICATE_SUB;
            case IDX_SAAS_SUPPLIER_COMMUNICATE:
                return IDX_SAAS_SUPPLIER_COMMUNICATE_SUB;
            case IDX_SAAS_WORK_REPORT:
                return IDX_SAAS_WORK_REPORT_SUB;
            case IDX_SAAS_PURCHASE:
                return IDX_SAAS_PURCHASE_SUB;
            case IDX_SAAS_RETURNED_PURCHASE:
                return IDX_SAAS_RETURNED_PURCHASE_SUB;
            case IDX_SAAS_SUPPLIER_CONTACT:
                return IDX_SAAS_SUPPLIER_CONTACT_SUB;
            case IDX_SAAS_SUPPLIER:
                return IDX_SAAS_SUPPLIER_SUB;
            case IDX_SAAS_PRODUCT:
                return IDX_SAAS_PRODUCT_SUB;
            case IDX_SAAS_INVENTORY:
                return IDX_SAAS_INVENTORY_SUB;
            case IDX_SAAS_TRANSFER:
                return IDX_SAAS_TRANSFER_SUB;
            case IDX_SAAS_WAREHOUSE:
                return IDX_SAAS_WAREHOUSE_SUB;
            case IDX_SAAS_REFUND:
                return IDX_SAAS_REFUND_SUB;
            case IDX_SAAS_WORK_ORDER:
                return IDX_SAAS_WORK_ORDER_SUB;
            case IDX_SAAS_PAYMENT_TASK:
                return IDX_SAAS_PAYMENT_TASK_SUB;
            case IDX_SAAS_CLUE:
                return IDX_SAAS_CLUE_SUB;
            case IDX_SAAS_MARKET_ACTIVITY:
                return IDX_SAAS_MARKET_ACTIVITY_SUB;
            case IDX_SAAS_CREDIT_TEMPORARY_LIMIT:
                return IDX_SAAS_CREDIT_TEMPORARY_LIMIT_SUB;
            case IDX_SAAS_CREDIT_FIXED_LIMIT:
                return IDX_SAAS_CREDIT_FIXED_LIMIT_SUB;
            case IDX_SAAS_OTHER_INCOME:
                return IDX_SAAS_OTHER_INCOME_SUB;
            case IDX_SAAS_OTHER_EXPENSE:
                return IDX_SAAS_OTHER_EXPENSE_SUB;
            case IDX_SAAS_FUND_TRANSFER:
                return IDX_SAAS_FUND_TRANSFER_SUB;
            case IDX_SAAS_COST_ADJUST:
                return IDX_SAAS_COST_ADJUST_SUB;
            case IDX_SAAS_COMPETITOR:
                return IDX_SAAS_COMPETITOR_SUB;
            case IDX_RECEIPT_ORDER:
                return IDX_RECEIPT_ORDER_SUB;
            case IDX_SERVICE_PROJECT:
                return IDX_SERVICE_PROJECT_SUB;
            case IDX_WORK_ORDER_V2:
                return IDX_WORK_ORDER_V2_SUB;
            default:
                break;
        }
        return UNKNOWN;
    }

    public static boolean isSubform(IndexTypeEnum indexTypeEnum) {
        boolean flag = false;
        if(indexTypeEnum == null){
            return false;
        }
        switch (indexTypeEnum) {
            case IDX_SUB_FORM_DATA:
            case IDX_SAAS_CUSTOMER_TEAM:
            case IDX_SAAS_CUSTOMER_SUB:
                // 特殊索引
            case IDX_SAAS_CUSTOMER_TEAM_SPECIAL:
            case IDX_SAAS_CUSTOMER_SUB_SPECIAL:
            case IDX_SAAS_CLUE_TEAM:
            case IDX_SAAS_CLUE_SUB:
            case IDX_SAAS_CONTRACT_PRODUCT:
            case IDX_SAAS_CONTRACT_TEAM:
            case IDX_SAAS_CONTRACT_PERFORMANCE:
            case IDX_SAAS_CONTRACT_SUB:
            case IDX_SAAS_QUOTATION_TEAM:
            case IDX_SAAS_QUOTATION_SUB:
            case IDX_SAAS_OUTSTOCK_SUB:
            case IDX_SAAS_CONTACT_TEAM:
            case IDX_SAAS_CONTACT_SUB:
            case IDX_SAAS_INVOICE_SUB:
            case IDX_SAAS_PURCHASE_INVOICE_SUB:
            case IDX_SAAS_INSTOCK_SUB:
            case IDX_SAAS_ASSEMBLE_SUB:
            case IDX_SAAS_PAYMENT_TEAM:
            case IDX_SAAS_PAYMENT_SUB:
            case IDX_SAAS_PAYMENT_SHEET_TEAM:
            case IDX_SAAS_PAYMENT_SHEET_SUB:
            case IDX_SAAS_PAYPLAN_SHEET_TEAM:
            case IDX_SAAS_PAYPLAN_SHEET_SUB:
            case IDX_SAAS_PRODUCTION_ORDER_TEAM:
            case IDX_SAAS_PRODUCTION_ORDER_SUB:
            case IDX_SAAS_PAY_PLAN_TEAM:
            case IDX_SAAS_PAY_PLAN_SUB:
            case IDX_SAAS_COMMUNICATE_PLAN_TEAM:
            case IDX_SAAS_COMMUNICATE_PLAN_SUB:
            case IDX_SAAS_OPPORTUNITY_TEAM:
            case IDX_SAAS_OPPORTUNITY_SUB:
            case IDX_SAAS_BOM_TEAM:
            case IDX_SAAS_BOM_SUB:
            case IDX_SAAS_CUSTOMER_COMMUNICATE_SUB:
            case IDX_SAAS_SUPPLIER_COMMUNICATE_SUB:
            case IDX_SAAS_WORK_REPORT_SUB:
            case IDX_SAAS_PURCHASE_TEAM:
            case IDX_SAAS_PURCHASE_SUB:
            case IDX_SAAS_RETURNED_PURCHASE_SUB:
            case IDX_SAAS_SUPPLIER_CONTACT_TEAM:
            case IDX_SAAS_SUPPLIER_CONTACT_SUB:
            case IDX_SAAS_SUPPLIER_TEAM:
            case IDX_SAAS_SUPPLIER_SUB:
            case IDX_SAAS_PRODUCT_TEAM:
            case IDX_SAAS_PRODUCT_WAREHOUSE:
            case IDX_SAAS_PRODUCT_STOCK_INFO:
            case IDX_SAAS_PRODUCT_SUB:
            case IDX_SAAS_INVENTORY_SUB:
            case IDX_SAAS_TRANSFER_SUB:
            case IDX_SAAS_WAREHOUSE_SUB:
            case IDX_SAAS_REFUND_TEAM:
            case IDX_SAAS_REFUND_SUB:
            case IDX_SAAS_WORK_ORDER_TEAM:
            case IDX_SAAS_WORK_ORDER_CC:
            case IDX_SAAS_WORK_ORDER_SUB:
            case IDX_PAYMENT_BALANCE_TEAM:
            case IDX_PAY_BALANCE_TEAM:
            case IDX_SAAS_PAYMENT_TASK_SUB:
            case IDX_SAAS_PAYMENT_TASK_TEAM:
            case IDX_SAAS_CUSTOMER_STATEMENT_SNAPSHOT:
            case IDX_SAAS_OTHER_INCOME_SUB:
            case IDX_SAAS_OTHER_EXPENSE_SUB:
            case IDX_SAAS_FUND_TRANSFER_SUB:
            case IDX_SAAS_MARKET_ACTIVITY_TEAM:
            case IDX_SAAS_MARKET_ACTIVITY_SUB:
            case IDX_SAAS_CREDIT_TEMPORARY_LIMIT_SUB:
            case IDX_SAAS_CREDIT_FIXED_LIMIT_SUB:
            case IDX_FORM_DATA_TEAM:
            case IDX_SAAS_COMPETITOR_TEAM:
            case IDX_SLA_LOG_DATA_TEAM:
            case IDX_SERVICE_PROJECT_TEAM:
            case IDX_RECEIPT_ORDER_TEAM:
            case IDX_SERVICE_PROJECT_SUB:
            case IDX_RECEIPT_ORDER_PRODUCT:
            case IDX_RECEIPT_ORDER_SUB:
            case IDX_WORK_ORDER_V2_TEAM:
            case IDX_WORK_ORDER_V2_PRODUCT:
            case IDX_WORK_ORDER_V2_SUB:
                flag = true;
            default:
        }
        return flag;
    }

    /**
     * 设置paas团队的index和type
     *
     * @param indexTypeEnum
     * @param saasMark
     */
    public  void setPaasTeamIndexTypeEnum(IndexTypeEnum indexTypeEnum, Integer saasMark) {
        if (Objects.equals(saasMark, SaasMarkEnum.PAAS.getCode())) {
            this.index = indexTypeEnum.getNoPrefixRealName();
            this.type = indexTypeEnum.getType();
        }
    }

    /**
     * 得到没有前缀的实际索引名称
     *
     * @return
     */
    public String getNoPrefixRealName(){
        return realName;
    }
}
